//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace WorkflowApplicationControls
{
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using Microsoft.Research.ScientificWorkflow.UIDesigner;

    /// <summary>
    /// Interaction logic for DetailsControl.xaml
    /// </summary>
    public sealed partial class DetailsControl : UserControl
    {
        private PropertyListControl workflowRequiredPropertyList;
        public DetailsControl()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(this.OnLoaded);
        }

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            RunControlPresenter presenter = this.DataContext as RunControlPresenter;
            if (presenter != null)
            {
                // Add the property list to the window.
                workflowRequiredPropertyList = new PropertyListControl();

                Binding propertyValidityBinding = new Binding("PropertiesValid");
                propertyValidityBinding.Source = this.DataContext;
                propertyValidityBinding.Mode = BindingMode.TwoWay;
                workflowRequiredPropertyList.SetBinding(PropertyListControl.PropertiesValidProperty, propertyValidityBinding);

                workflowRequiredPropertyList.CurrentValidationMode = ValidationMode.All;
                workflowRequiredPropertyList.Parameters = presenter.WorkflowRequiredParameters;

                this.PropertyPaneHost.Content = workflowRequiredPropertyList;
            }
        }
    }
}
